package com.jp.knowledge.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.jp.knowledge.R;

/**
 * 背景加载dialog
 */

public class BgLoadingDialog extends Dialog {

    public BgLoadingDialog(final Context context) {
        super(context, R.style.bg_loading_dialog);

        this.setCanceledOnTouchOutside(false);
//        this.setCancelable(false);
        this.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                ((Activity)context).finish();
            }
        });
        View view = View.inflate(context, R.layout.dialog_bg_loading, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.bg_icon);
        Glide.with(getContext()).load(R.drawable.bg_loading_dialog).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);
        this.setContentView(view);
    }
}
